﻿#include "OperGeometrySolid.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "OperatorsInterface/GraphEventOperator.h"
#include <QWidget>
#include "GUIDialog/GUIGeometryDialog/GUIGeometrySolidDialog.h"


bool ModelOper::OperGeometrySolid::execGUI(){
    //获取动作名称
    QString actionName = _emitter->objectName();
    if (actionName == "actionSolidChoosePlane")//由封闭面创建体
    {
        this->createSolidFromChoosePlaneOper();
    }
    return false;
}

bool ModelOper::OperGeometrySolid::execProfession()
{
    //获取此次要建模时候的检查函数的返回值
    /*bool check_state = false;
    this->argValue("check_state", check_state);
    if (check_state==false)
    {
        return false;
    }*/

    int objID = -1;
    this->argValue("objID", objID);
    //获取三维可视对象数据-用于渲染数据对象
    EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
    if (graphOper == nullptr)return false;
    graphOper->updateGraph(objID);
    return true;
}

bool ModelOper::OperGeometrySolid::createSolidFromChoosePlaneOper()
{
    //主界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建封闭面创建体界面
    GUI::GUIGeometrySolidDialog* dialog = new GUI::GUIGeometrySolidDialog(this, mw);
    if (dialog==nullptr)return false;
    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometrySolid::execProfession);
    dialog->show();
    return true;
}

